home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*--------------------*
- * CPPLGEN2.C *
- * Mouse programs *
- * & utilities *
- *--------------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
- # include <graphics.h>
-
- /* Global Variables */
- extern int i,j,k,l,m,n,t,x,x1,x2,xm,xms,y,y1,y2,ym,yms,z,soundvar,returning;
- extern int colour1,colour2,colour3,colour4,colour5,cardtype,divx,divy;
- extern int menu0,menu1,menu2,menu3,menu4,menu5,menu6,menu7,menu8;
- extern int pfdiv,pfserv,pfhelp,menu9,menu10;
- extern unsigned char c0,c1,nc1[],trashcan[],trashret[],name[];
-
- /*----------------------*
- * GAMES WITH THE MOUSE *
- *----------------------*/
- int games_with_the_mouse()
- {
- returning=check_the_mouse();
- if(returning==1){
- show_the_mouse(); /* limit_the_mouse(); */
- return(1);
- }
- else{
- /* The mouse is not connected or the driver is not loaded */
- warning(" Mouse not connected "," or driver not loaded "," Press <Enter> ","","");
- return(0);
- }
- }
- /*---------------*
- * MOUSE FACTORS *
- *---------------*/
- void mouse_factors()
- {
- if((cardtype<4)||(cardtype==9)||(cardtype==10)){
- divx=8; divy=8;
- return;
- }
- if((cardtype>3)&&(cardtype<7)){
- divx=8; divy=14;
- return;
- }
- if(cardtype==7){
- /* ? Hercules 720x348 ? */
- divx=9; divy=12;
- return;
- }
- if(cardtype==8){
- divx=8; divy=16;
- return;
- }
- if(cardtype==11){
- divx=9; divy=14;
- return;
- }
- }
- /*----------------------------*
- * READ VIDEO CARD *
- *----------------------------*/
- void read_video_card()
- {
- int graphdriver,graphmode,errorcode;
- detectgraph(&graphdriver,&graphmode);
- errorcode=graphresult();
- if(errorcode !=0){
- warning(" Reading error "," of the videocard ",""," Press a Key ","");
- return;
- }
- cardtype=0;
- /* 320x200x4c CGA */
- if((graphdriver==1)&&(graphmode<4)) cardtype=1;
- /* 640x200x2c CGA */
- if((graphdriver==1)&&(graphmode==4)) cardtype=2;
- /* 320x200x4c MCGA */
- if((graphdriver==2)&&(graphmode<4)) cardtype=1;
- /* 640x200x2c MCGA */
- if((graphdriver==2)&&(graphmode==4)) cardtype=2;
- /* 640x480x2c MCGA */
- if((graphdriver==2)&&(graphmode==5)) cardtype=10;
- /* 640x200x16c EGA */
- if((graphdriver==3)&&(graphmode==0)) cardtype=3;
- /* 640x350x16c EGA */
- if((graphdriver==3)&&(graphmode==1)) cardtype=4;
- /* 640x200x16c EGA 64 */
- if((graphdriver==4)&&(graphmode==0)) cardtype=3;
- /* 640x350x4c EGA 64 */
- if((graphdriver==4)&&(graphmode==1)) cardtype=5;
- /* 640x350x2c EGA MONO */
- if((graphdriver==5)&&(graphmode==3)) cardtype=6;
- /* 720x348x2c Hercules MONO */
- if((graphdriver==7)&&(graphmode==0)) cardtype=7;
- /* 320x200x4c ATT 400 */
- if((graphdriver==8)&&(graphmode<4)) cardtype=1;
- /* 640x200x2c ATT 400 */
- if((graphdriver==8)&&(graphmode==4)) cardtype=2;
- /* 640x400x2c ATT 400 */
- if((graphdriver==8)&&(graphmode==5)) cardtype=8;
- /* 640x200x16c VGA */
- if((graphdriver==9)&&(graphmode==0)) cardtype=3;
- /* 640x350x16c VGA */
- if((graphdriver==9)&&(graphmode==1)) cardtype=4;
- /* 640x480x16c VGA */
- if((graphdriver==9)&&(graphmode==2)) cardtype=9;
- /* 720x350x2c PC 3270 */
- if((graphdriver==10)&&(graphmode==0)) cardtype=11;
- if(cardtype==0){
- warning(" Reading error "," of the videocard ",""," Press a Key ","");
- return;
- }
- /* As the mouse co-ordinates are in pixels */
- /* we calculate the needed factors */
- mouse_factors();
- }
- /*----------------------------------*
- * RE-INIT INIT VARIABLES *
- *----------------------------------*/
- void re_init_init_variables()
- {
- /* The window is the whole screen */
- x1=1; x2=80;
- y1=1; y2=25;
- /* The mouse is put in the upper-left corner */
- xms=2; yms=1;
- /* Put the handles to -1 to indicate that these files */
- /* are not open (test case) */
- pfdiv=-1; pfserv=-1;
- pfhelp=-1;
- /* No menu is displayed */
- menu0=0; menu1=1;
- menu2=1; menu3=1;
- menu4=1; menu5=1;
- menu6=1; menu7=1;
- menu8=1; menu9=1;
- menu10=1;
-
- }
- /*----------------------------------*
- * RE-INIT PROGRAM VARIABLES *
- *----------------------------------*/
- void re_init_program_variables()
- {
- randomize(); soundvar=1;
- /* We have to init the other data */
- /* strcpy(name," "); name[19]=0x00; */
-
- }
- /*----------------------*
- * INIT PROGRAM *
- *----------------------*/
- int program_init()
- {
- /* init the variables */
- re_init_init_variables();
- re_init_program_variables();
- read_video_card();
- if((read_hardware_config())==0) return(0);
- return(1);
- }
- /*----------------------------------------*
- * GET OR CHANGE A WORD (xx,yy,nbcar) *
- *----------------------------------------*/
- int get_or_change_a_word(xx,yy,nbcar)
- int xx,yy,nbcar;
- {
- /* First copy the sent word */
- strcpy(trashret,trashcan);
- /* Then fill it with spaces */
- sound1(); j=strlen(trashcan);
- for(i=j; i<(nbcar-1); i++) trashret[i]=0x20;
- i=0;
- nc1[0]=0x20; nc1[1]=0x00;
- while(1){
- textattr(colour4);
- gotoxy(xx,yy); cputs(trashret);
- textattr(colour5); nc1[0]=trashret[i];
- gotoxy((xx+i),yy); cputs(nc1);
- c0=getch();
- if(c0==27){
- blank_line_25(); return(0);
- }
- if(c0==13) break;
- if(c0==0){
- c1=getch();
- if(c1==83){
- /* Suppression */
- for(j=i; j<nbcar; j++) trashret[j]=trashret[j+1];
- trashret[nbcar-1]=0x20;
- }
- if(c1==77){
- /* Right arrow */
- if(i<nbcar-2) i++;
- }
- if(c1==75){
- /* Left arrow */
- if(i>0) i--;
- }
- if(c1==71){
- /* Beginning */
- i=0;
- }
- if(c1==79){
- /* End */
- i=nbcar-1;
- }
- }
- if((c0>31)&&(c0<179)){
- /* legal char */
- nc1[0]=c0; trashret[i]=c0;
- if(i<nbcar-1) i++;
- }
- if(c0==8){
- /* Go backward */
- i--;
- for(j=i; j<(nbcar-1); j++) trashret[j]=trashret[j+1];
- trashret[nbcar-1]=0x20;
- }
- }
- /* If we entered more chars than allowed, we cut there the word */
- blank_line_25(); trashret[nbcar]=0x00;
- return(1);
- }
- /* End of the Module *//*-----------------*/
-
-